using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using SchEdu.Framework.Exceptions;


namespace SchEdu.Framework.DataModel
{
    public enum MachineEnvironment
    {
        None,
        SingleMachine,
        ParellelMachine,
        FlowShop,
        FlexibleFlowShop,
        JobShop,
        FlexibleJobShop
    };

    [Serializable()]
    public class SchEduData 
    {

        public SchEduDataSet.OrderDataTable Order
        {
            get
            {
                return schEduDataSet.Order;
            }
        }


        public SchEduDataSet.WorkCenterDataTable WorkCenter
        {
            get
            {
                return schEduDataSet.WorkCenter;
            }
        }

        public SchEduDataSet.MachineDataTable Machine
        {
            get
            {
                return schEduDataSet.Machine;
            }
        }

        public SchEduDataSet.OperationDataTable Operation
        {
            get
            {
                return schEduDataSet.Operation;
            }
        }


        public SchEduDataSet.AllocationDataTable Allocation
        {
            get
            {
                return schEduDataSet.Allocation;
            }
        }

        public SchEduDataSet.DependencyDataTable Dependency
        {
            get
            {
                return schEduDataSet.Dependency;
            }
        }

        public SchEduDataSet.SetupTimeDataTable SetupTime
        {
            get
            {
                return schEduDataSet.SetupTime;
            }
        }

        public SchEduDataSet.SolutionDataTable Solution
        {
            get
            {
                return schEduDataSet.Solution;
            }
        }

        public SchEduDataSet.ConstraintDataTable Constraint
        {
            get
            {
                return schEduDataSet.Constraint;
            }
        }


        public SchEduDataSet.PerformanceDataTable Performance
        {
            get
            {
                return schEduDataSet.Performance;
            }
        }

        #region Scheduling DataSet
        SchEduDataSet schEduDataSet = new SchEduDataSet();

        public SchEduDataSet SchEduDataSet
        {
            get { return schEduDataSet; }
            set { schEduDataSet = value; }
        }
        #endregion

        public SchEduData()
        {
        }

        public void RefreshAdditionalFields()
        {
            foreach (SchEduDataSet.WorkCenterRow workCenter in schEduDataSet.WorkCenter)
            {
                workCenter.SetAvailabilityDateNull();
            }
            foreach (SchEduDataSet.MachineRow machine in schEduDataSet.Machine)
            {
                machine.SetAvailabilityDateNull();
            }

            foreach (SchEduDataSet.OrderRow order in schEduDataSet.Order)
            {
                order.SetProcessingTimeNull();
                order.SetStartDateNull();
                order.SetEndDateNull();

   
                foreach (SchEduDataSet.OperationRow operation in order.GetOperationRows())
                {
                    order.ProcessingTime += operation.ProcessingTime;
                    operation.AvailabilityDate = 0;
                    operation.DueDate = order.DueDate;
                }
 
            }

        }

    }
}
